export const getAppData = () => {
  return getApp().globalData;
};

export const getInitFinish = () => {
  const appData = getAppData();
  return appData.initFinish;
};

export const checkInitFinish = () => {
  const fn = (resolve, reject) => {
    const initFinish = getInitFinish();
    if (initFinish) {
      resolve(true);
      return;
    }
    setTimeout(() => {
      fn(resolve, reject);
    }, 300);
  };
  return new Promise((resolve, reject) => {
    fn(resolve, reject);
  });
};

export default {
  getAppData,
  checkInitFinish,
};
